package cn.itbox.example.application.controller;

import javax.xml.crypto.Data;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @BelongProject springboot-study
 * @BelongPackage cn.itbox.example.application.controller
 * @Description TODO
 * @ClassName ReentrantWriteAndReadLockTest
 * @Author huyanbing
 * @Date 2024/3/5 20:01
 * @Version 1.0.0
 */
public class ReentrantWriteAndReadLockTest {

    private ReadWriteLock readWriteLock=new ReentrantReadWriteLock();

    private Lock r=readWriteLock.readLock();

    private Lock w=readWriteLock.writeLock();


    //读操作上读锁
//    public Data  get(String key){
//
//
//    }


//
//    // 读操作上读锁
//    public Data get(String key) {
//        r.lock();
//        try {
//            // TODO 业务逻辑
//        }finally {
//            r.unlock();
//        }
//    }
//
//    // 写操作上写锁
//    public Data put(String key, Data value) {
//        w.lock();
//        try {
//            // TODO 业务逻辑
//        }finally {
//            w.unlock();
//        }
//    }
}
